//
//  GTUMSocialShare.m
//  GiftTalk
//
//  Created by Wan on 16/3/29.
//  Copyright © 2016年 Wan. All rights reserved.
//  UM 分享帮助类

#import "GTUMSocialShare.h"
#import "UMSocialSnsPlatformManager.h"
#import "UMSocialConfig.h"
#import "UMSocialSnsService.h"

@implementation GTUMSocialShare

/**
 *  UM社会化分享
 *
 *  @param presentVc   从哪个控制器弹出分享按钮
 *  @param shareImage  分享内嵌图片
 *  @param description 分享内容的描述
 *  @param url         分享内容的 url
 */
+ (void)shareByPresentVc:(UIViewController *)presentVc shareImage:(UIImage *)shareImage shareDescription:(NSString *)description shareUrl:(NSString *)url
{
    
    NSString *appKey = @"56fa42d367e58ef6fc001ad7";
    NSString *shareText = [NSString stringWithFormat:@"%@,%@", description, url];
    NSArray *snsNames = @[UMShareToSina, UMShareToWechatSession, UMShareToWechatTimeline,
                          UMShareToEmail, UMShareToDouban, UMShareToRenren];
    
    [UMSocialConfig setTheme:UMSocialThemeBlack];
    
    [UMSocialConfig setShareGridViewTheme:^(CGContextRef ref, UIImageView *backgroundView,UILabel *label){
        //改变线颜色和线宽
        CGContextSetRGBStrokeColor(ref, 0, 0, 0, 1.0);
        CGContextSetLineWidth(ref, 1.0);
        //改变背景颜色
        backgroundView.backgroundColor = [UIColor blackColor];
        
        //添加背景图片
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:backgroundView.frame];
        imageView.image = [UIImage imageNamed:@"Me_ProfileBackground"];
        [backgroundView addSubview:imageView];
        backgroundView.backgroundColor = [UIColor clearColor];
        
        //改变文字标题的文字颜色
        label.textColor = [UIColor blueColor];
        //隐藏文字
        label.hidden = YES;
    }];
    
    [UMSocialSnsService presentSnsIconSheetView:presentVc
                                         appKey:appKey
                                      shareText:shareText
                                     shareImage:shareImage
                                shareToSnsNames:snsNames
                                       delegate:nil];
    
    //    NSDictionary *dict = [UMSocialSnsPlatformManager sharedInstance].allSnsPlatformDictionary;
    //
    //    UMSocialSnsPlatform *douban = dict[@"douban"];
    ////    douban.bigImageName = @"sns_icon_5";
    //    douban.smallImageName =  @"sns_icon_5";
    //
    //    UMSocialSnsPlatform *renren = dict[@"renren"];
    //    renren.bigImageName = @"sns_icon_7";
    
}

@end
